import axios from '../../http/http'

const store = {
    namespaced: true,
    state(){
        return {
            adminList: [],
            total:0
        }    
    },
    actions:{
        getAdminAction(context,pageObj){
            axios.get("/userlist",
                    {
                        params:pageObj
                    }
                ).then(
                res=> {
                    context.commit("getAdminMutations",res.data.list)
                }
            )
        },
        getAdminCountAciton({commit}){
            axios.get("/usercount").then(
                res=>{
                    if(res.status == 200){
                        commit("getAdminCountMutations",res.data.list[0].total)
                    }
                }
            )
        }
    },
    mutations: {  
        getAdminCountMutations(state,total){
           state.total=total
        },
        getAdminMutations(state,list){
            state.adminList = list
        }
    }

}

export default store